<template>
     <div class="grid-content bg-purple">
         <el-form ref="form" :model="form" label-width="120px" size="small">
             <el-form-item label="原始密码">
                 <el-input type="password" v-model="form.oldpwd"></el-input>
             </el-form-item>
             <el-form-item label="新密码">
                 <el-input type="password" v-model="form.pwd"></el-input>
             </el-form-item>
             <el-form-item label="确认密码">
                 <el-input type="password" v-model="form.pwd_confirmation"></el-input>
             </el-form-item>
             <el-form-item>
                 <el-button  type="primary" @click="changePwd">确认</el-button>
             </el-form-item>
         </el-form>
     </div>
</template>

<script>
import {resetPwd} from '@/backend/api/login'
export default {
    name: 'ResetPwd',
    data() {
        return {
            form: {
                oldpwd: '',
                pwd: '',
                pwd_confirmation: '',
            }
        }
    },
    created() {
        this.form.oldpwd= ''
        this.form.pwd= ''
        this.form.pwd_confirmation= ''
    },
    methods: {
        changePwd() {
            resetPwd(this.form).then(res => {
                if (res.status == 0){
                    // alert('成功');
                    this.$store.dispatch('update_usertoken', res.result)
                    this.$message({
                        message: res.message,
                        type: 'success',
                        duration: 1000,
                    });
                    // location.reload()
                } else {
                    this.$message({
                        message: res.message,
                        type: 'warning',
                        duration: 1500,
                    });
                }
            })
        }
    }
}
</script>

<style lang="scss" scope>
//    .resetpwd-body {
//         -webkit-box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
//         box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
//         padding: 10px 10px 30px 10px;
//         border-radius: 6px;
//         background: #fff;
//     }
</style>


